﻿Namespace DotNetNuke.Modules.ActiveForums
    Partial Public Class profile_adminsettings
        Inherits ProfileBase
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim ui As UserProfileInfo = UserProfile
            If ui Is Nothing And UID > 0 Then
                Dim up As New UserController
                ui = up.GetUser(PortalId, ForumModuleId, UID).Profile
            End If
            
            If Not ui Is Nothing Then
                With ui
                    txtRewardPoints.Text = .RewardPoints.ToString
                    txtUserCaption.Text = .UserCaption
                    chkDisableSignature.Checked = .SignatureDisabled
                    chkDisableAttachments.Checked = .AttachDisabled
                    chkDisableAvatar.Checked = .AvatarDisabled
                    chkMonitor.Checked = .AdminWatch
                    drpDefaultTrust.SelectedIndex = drpDefaultTrust.Items.IndexOf(drpDefaultTrust.Items.FindByValue(.TrustLevel.ToString))
                    txtRewardPoints.Attributes.Add("onkeypress", "return onlyNumbers(event);")
                End With
            End If

        End Sub

        Private Sub cbAdmin_Callback(ByVal sender As Object, ByVal e As Modules.ActiveForums.Controls.CallBackEventArgs) Handles cbAdmin.Callback
            If Not CurrentUserType = CurrentUserTypes.Anon And Not CurrentUserType = CurrentUserTypes.Auth Then
                Dim upc As New UserProfileController
                Dim uc As New UserController
                Dim upi As UserProfileInfo = uc.GetUser(PortalId, ForumModuleId, UID).Profile
                If Not upi Is Nothing Then
                    With upi
                        .RewardPoints = CInt(e.Parameters(1))
                        .UserCaption = e.Parameters(2).ToString
                        .SignatureDisabled = CBool(e.Parameters(3))
                        .AvatarDisabled = CBool(e.Parameters(4))
                        .TrustLevel = CInt(e.Parameters(5))
                        .AdminWatch = CBool(e.Parameters(6))
                        .AttachDisabled = CBool(e.Parameters(7))
                    End With
                    upc.Profiles_Save(upi)
                End If
            End If
        End Sub
    End Class
End Namespace
